package com.ys168.gam.bean;

import com.ys168.gam.basic.IRenderText;

/**
 * @author Jason Krebs
 * @since 2015年6月12日
 */
public class TypeInfo implements IRenderText {

    private String code;
    private String name;

    public TypeInfo(String code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof TypeInfo)) {
            return false;
        }

        TypeInfo other = (TypeInfo) obj;
        if (code == null) {
            return other.code == null;
        }

        return code.equals(other.code);
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    @Override
    public int hashCode() {
        if (code == null) {
            return 0;
        }

        return code.hashCode();
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        if (code == null) {
            return "null/" + name;
        }
        return code + "/" + name;
    }

    @Override
    public String getText() {
        return getName();
    }
}
